<?php
namespace app\index\controller;

use app\index\model\NewsModel;
use app\index\model\SceneryModel;
use think\Request;
use think\View;

class Scenery extends Base
{
    public function __construct(Request $request) {
        parent::__construct($request);
        View::share ('menuNow', '/scenery.html');
    }

    /**
     * @param Request $request
     * @return \think\response\View
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function lists (Request $request)
    {
        $sceneryModel = new SceneryModel();
        $map = [];
        $type = $request->get ('type');
        $list = $sceneryModel->getList ($map, $request->get ('page'), 5);
        return view ('lists', [
            'list' => $list,
        ]);
    }

    /**
     * @param Request $request
     * @return \think\response\View
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function detail (Request $request)
    {
        $id = $request->route ('id');
        $sceneryModel = new SceneryModel();
        $detail = $sceneryModel->getDetails (['s.id' => $id]);
        return view ('detail', [
            'title'       => $detail['name'] . '简介-',
            'detail'      => $detail,
            'description' => $detail['name'] . ',',
        ]);
    }
}
